﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AdvanceLib.Core
{
    public class LineParser
    {
        #region Constructors
        public LineParser()
        {
            this.Lines = new List<Line>();
        }
        #endregion

        #region Properties
        public List<Line> Lines { get; set; }
        #endregion

        #region Methods
        public void Parse(string input) { this.Parse(input, Constants.NEW_LINE); }
        public void Parse(string input, char lineSeperator)
        {
            int currentLine = 0;
            string[] lines = input.Split(new char[] { lineSeperator });

            foreach (string line in lines)
            {
                string[] lineParts = line.Split(new char[] { Constants.WHITE_SPACE });
                this.Lines.Add(new Line() 
                { 
                    Content = line,
                    Index = currentLine++,
                    Parts = lineParts
                });
            }
        }
        #endregion
    }
}
